package com.ruoyi.schoolSys.service.impl;

import java.util.HashMap;
import java.util.List;
import com.ruoyi.common.utils.DateUtils;
import com.ruoyi.schoolSys.model.vo.CourseClassVo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.ruoyi.schoolSys.mapper.CourseClassMapper;
import com.ruoyi.schoolSys.domain.CourseClass;
import com.ruoyi.schoolSys.service.ICourseClassService;

/**
 * 课程安排Service业务层处理
 * 
 * @author ruoyi
 * @date 2024-02-19
 */
@Service
public class CourseClassServiceImpl implements ICourseClassService 
{
    @Autowired
    private CourseClassMapper courseClassMapper;

    /**
     * 查询课程安排
     * 
     * @param id 课程安排主键
     * @return 课程安排
     */
    @Override
    public CourseClassVo selectCourseClassById(Long id)
    {
        return courseClassMapper.selectCourseClassById(id);
    }

    /**
     * 查询课程安排列表
     * 
     * @param courseClass 课程安排
     * @return 课程安排
     */
    @Override
    public List<CourseClassVo> selectCourseClassList(CourseClass courseClass)
    {
        return courseClassMapper.selectCourseClassList(courseClass);
    }

    /**
     * 新增课程安排
     * 
     * @param courseClass 课程安排
     * @return 结果
     */
    @Override
    public int insertCourseClass(CourseClass courseClass)
    {
        courseClass.setCreateTime(DateUtils.getNowDate());
        HashMap<String, Integer> weekNumMap = new HashMap<>();
        HashMap<String, Integer> classNumMap = new HashMap<>();
        weekNumMap.put("星期一", 1);
        weekNumMap.put("星期二", 2);
        weekNumMap.put("星期三", 3);
        weekNumMap.put("星期四", 4);
        weekNumMap.put("星期五", 5);

        classNumMap.put("第一节", 1);
        classNumMap.put("第二节", 2);
        classNumMap.put("第三节", 3);
        classNumMap.put("第四节", 4);
        classNumMap.put("第五节", 5);
        courseClass.setWeekNumFigure(weekNumMap.get(courseClass.getWeekNum()));
        courseClass.setClassNumFigure(classNumMap.get(courseClass.getClassNum()));
        return courseClassMapper.insertCourseClass(courseClass);
    }

    /**
     * 修改课程安排
     * 
     * @param courseClass 课程安排
     * @return 结果
     */
    @Override
    public int updateCourseClass(CourseClass courseClass)
    {
        courseClass.setUpdateTime(DateUtils.getNowDate());
        return courseClassMapper.updateCourseClass(courseClass);
    }

    /**
     * 批量删除课程安排
     * 
     * @param ids 需要删除的课程安排主键
     * @return 结果
     */
    @Override
    public int deleteCourseClassByIds(Long[] ids)
    {
        return courseClassMapper.deleteCourseClassByIds(ids);
    }

    /**
     * 删除课程安排信息
     * 
     * @param id 课程安排主键
     * @return 结果
     */
    @Override
    public int deleteCourseClassById(Long id)
    {
        return courseClassMapper.deleteCourseClassById(id);
    }
}
